#ifdef __GNUG__
#pragma implementation "TimeSeriesDataset.h"
#endif

#include <wx/xy/xyplot.h>
#include <wx/xy/xylinerenderer.h>

#include <wx/axis/numberaxis.h>
#include <wx/axis/dateaxis.h>
#include "TimeSeriesDataset.h"

//IMPLEMENT_CLASS(TimeSeriesDataset, XYDataset)

TimeSeriesDataset::TimeSeriesDataset(double *data, time_t *times, size_t count)
{
	m_data = new double[count];
	m_times = new time_t[count];
	m_count = count;

	for (size_t n = 0; n < count; n++) {
		m_data[n] = data[n];
		m_times[n] = times[n];
	}
}

TimeSeriesDataset::~TimeSeriesDataset()
{
	m_count = 0;
	wxDELETEA(m_data);
	wxDELETEA(m_times);
}

size_t TimeSeriesDataset::GetSerieCount()
{
	return 1;
}

size_t TimeSeriesDataset::GetCount(size_t WXUNUSED(serie))
{
	return m_count;
}

size_t TimeSeriesDataset::GetCount()
{
	return m_count;
}

wxString TimeSeriesDataset::GetSerieName(size_t WXUNUSED(serie))
{
	return wxT("Time series");
}

double TimeSeriesDataset::GetX(size_t index, size_t WXUNUSED(serie))
{
	return index;
}

double TimeSeriesDataset::GetY(size_t index, size_t WXUNUSED(serie))
{
	return m_data[index];
}

time_t TimeSeriesDataset::GetDate(size_t index)
{
	return m_times[index];
}

DateTimeDataset *TimeSeriesDataset::AsDateTimeDataset()
{
	return this;
}
